﻿using System;
using System.Windows.Markup;
using XEvolve.Core.Runtime;

namespace XEvolve.Presentation.Markup
{
    public class ServiceLocatorExtension : MarkupExtension
    {
        internal static IServiceLocator ServiceLocator;
        private readonly Type api;        

        public ServiceLocatorExtension(Type api)
        {
            this.api = api;
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return ServiceLocator.GetService(api);
        }
    }
}
